#include <iostream>
#include <cstdlib>
#include <assert.h>
#include "request.h"
using namespace std;

#define NUM_TEST_ELEMENTS 5

int main(int argc, char**argv) {
	int disk_track, disk_work;
	
	int original_disk_track [NUM_TEST_ELEMENTS];
	int original_disk_work [NUM_TEST_ELEMENTS];
	request* requests[NUM_TEST_ELEMENTS];
	
	// Create request objects
	request* tempReq;
	for (int i=0; i < NUM_TEST_ELEMENTS; i++) {
		disk_track = i + rand() % 16;
		disk_work = i + rand() % 100;
		original_disk_track[i] = disk_track;
		original_disk_work[i] = disk_work;
		tempReq = new request(disk_track, disk_work);
		requests[i] = tempReq;
		cout << "New request #: " << i+1 << " with track: " <<  disk_track << " and work: " << disk_work << "." << endl;
	}
	
	// Test request objects
	for (int i=0; i < NUM_TEST_ELEMENTS; i++) {
		// TEST1 - getTrackNum and getWorkSize
		assert(original_disk_track[i] == requests[i]->getTrackNum());
		assert(original_disk_work[i] == requests[i]->getWorkSize());
		assert(!requests[i]->getWorkFinished());
		cout << "Request #" << i << " passed TEST1..." << endl;
		// TEST2 - setTrackNum, setWorkSize, and setWorkFinished
		if (requests[i]->setTrackNum(5) &&
			requests[i]->setWorkSize(6) &&
			requests[i]->setWorkFinished(true)) {
			assert(5 == requests[i]->getTrackNum());
			assert(6 == requests[i]->getWorkSize());
			assert(requests[i]->getWorkFinished());
			cout << "Request #" << i << " passed TEST2..." << endl;
		} else {
			cout << "FAILED IN TEST2!" << endl;
		}
	}
	
	// Cleanup
	for (int i=0; i < NUM_TEST_ELEMENTS; i++) {
		delete requests[i];
	}
	
	return 0;
}
